package wang.j100.uc.module.system.dal.mysql.social;

import wang.j100.uc.framework.common.pojo.PageResult;
import wang.j100.uc.framework.mybatis.core.mapper.BaseMapperX;
import wang.j100.uc.framework.mybatis.core.query.LambdaQueryWrapperX;
import wang.j100.uc.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
import wang.j100.uc.module.system.dal.dataobject.social.SubSocialClientDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SocialClientMapper extends BaseMapperX<SubSocialClientDO> {

    default SubSocialClientDO selectBySocialTypeAndUserType(Integer socialType, Integer userType) {
        return selectOne(SubSocialClientDO::getSocialType, socialType,
                SubSocialClientDO::getUserType, userType);
    }

    default PageResult<SubSocialClientDO> selectPage(SocialClientPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SubSocialClientDO>()
                .likeIfPresent(SubSocialClientDO::getName, reqVO.getName())
                .eqIfPresent(SubSocialClientDO::getSocialType, reqVO.getSocialType())
                .eqIfPresent(SubSocialClientDO::getUserType, reqVO.getUserType())
                .likeIfPresent(SubSocialClientDO::getClientId, reqVO.getClientId())
                .eqIfPresent(SubSocialClientDO::getStatus, reqVO.getStatus())
                .orderByDesc(SubSocialClientDO::getId));
    }

}
